<?php
/**
 *
 * @author Tongle Xu <xutongle@gmail.com> 2012-10-31
 * @copyright Copyright (c) 2003-2103 yuncms.net
 * @license http://leaps.yuncms.net
 * @version $Id: Wincache.php 623 2013-07-29 03:40:03Z 85825770@qq.com $
 */
class Cache_Wincache extends Cache {
	
	/**
	 * (non-PHPdoc)
	 *
	 * @see Cache::init()
	 */
	public function init() {
		parent::init ();
		if (! extension_loaded ( 'wincache' )) throw new Exception ( 'The wincache extension must be loaded !' );
		if (! ini_get ( 'wincache.ucenabled' )) throw new Exception ( 'WinCache user cache is disabled. Please set wincache.ucenabled to On in your php.ini.' );
	}
	
	/**
	 * (non-PHPdoc)
	 *
	 * @see Cache::setValue()
	 */
	protected function setValue($key, $value, $expire = 0) {
		return wincache_ucache_set ( $key, $value, $expire );
	}
	
	/**
	 * (non-PHPdoc)
	 *
	 * @see Cache::getValue()
	 */
	protected function getValue($key) {
		return wincache_ucache_get ( $key );
	}
	
	/**
	 * (non-PHPdoc)
	 *
	 * @see Cache::addValue()
	 */
	protected function addValue($key, $value, $expire) {
		return wincache_ucache_add ( $key, $value, $expire );
	}
	
	/**
	 * (non-PHPdoc)
	 *
	 * @see Cache::deleteValue()
	 */
	protected function deleteValue($key) {
		return wincache_ucache_delete ( $key );
	}
	
	/**
	 * (non-PHPdoc)
	 *
	 * @see Cache::flushValues()
	 */
	public function flushValues() {
		return wincache_ucache_clear ();
	}
}